Skip to content

Conversation

@clouatre
Copy link

@clouatre clouatre commented Nov 6, 2025

Fixes #577

Problem

Tag spacing breaks when using fonts other than the default monospace font. The current implementation uses hardcoded negative margins (-me-3.5, -me-5) on the IconHash component, which are calibrated specifically for the default font. When users change fonts, the spacing breaks (as reported in #577).

Solution

Replace the negative margin approach with flexbox layout, matching the pattern already used by other icon+text components in AstroPaper:

  • Datetime component: Uses flex items-center gap-x-2
  • EditPost component: Uses flex gap-1.5
  • BackButton component: Uses flex

This makes Tag consistent with the rest of the codebase.

Changes

- <li class="group inline-block group-hover:cursor-pointer">
+ <li class="group group-hover:cursor-pointer">
    <a
-     class="relative pe-2 text-lg ..."
+     class="flex items-center gap-x-1.5 text-lg ..."
    >
      <IconHash
-       class="inline-block opacity-80"
-       { "-me-3.5 size-4": size === "sm" },
-       { "-me-5 size-6": size === "lg" },
+       class="opacity-80"
+       { "size-4": size === "sm" },
+       { "size-6": size === "lg" },
      />
-     &nbsp;<span>{tagName}</span>
+     <span>{tagName}</span>
    </a>
</li>

Benefits

Works with any font - Not calibrated to specific font metrics
Follows AstroPaper patterns - Matches Datetime, EditPost, BackButton components
Standard Tailwind CSS - Uses flex + gap, no magic numbers
Self-adjusting - Spacing adapts automatically to font changes
Cleaner code - Removes fragile negative margin approach

Testing

  • Tested with default font (works as before)
  • Tested with sans-serif font (fixes the spacing issue)
  • Build successful
  • No visual regression for users on default font

Related

As mentioned in #577 comment by @eerison: "I saw the same issue, when I used a different font."

@clouatre clouatre force-pushed the fix/tag-spacing-flexbox branch from bb42690 to d064175 Compare November 6, 2025 23:33
Fixes satnaing#577

## Problem
Tag spacing breaks when using fonts other than the default. The negative margins (-me-3.5, -me-5) are hardcoded for the default monospace font.

## Solution
Replace negative margin approach with flexbox layout, matching the pattern used by other icon+text components in AstroPaper (Datetime, EditPost, BackButton).

## Changes
- li: Removed 'inline-block' (not needed)
- a: Changed to 'flex items-center gap-x-1.5' (matches Datetime pattern)
- IconHash: Removed negative margins, use gap for spacing
- Removed &nbsp; entity (gap handles spacing)

## Benefits
- Works with any font (not calibrated to specific font)
- Follows existing AstroPaper component patterns
- Standard Tailwind CSS (no magic numbers)
- Self-adjusting spacing
@clouatre clouatre force-pushed the fix/tag-spacing-flexbox branch from d064175 to 0b2a2af Compare November 6, 2025 23:33
@clouatre
Copy link
Author

clouatre commented Nov 6, 2025

Closing to test more thoroughly and find a more elegant solution first.

@clouatre clouatre closed this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: fix: improve tag spacing on mobile devices

1 participant